package com.ljx.itbbs.server.mall.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-03-29  16:39
 */
@Getter
@AllArgsConstructor
public enum PaymentStatusEnum {

    DEFAULT(1, "待支付"),
    OK(2, "已支付"),
    LOSE(3, "已过期");

    private Integer type;
    private String desc;
    private static Map<Integer, PaymentStatusEnum> cache;

    static {
        cache = Arrays.stream(PaymentStatusEnum.values()).collect(Collectors.toMap(PaymentStatusEnum::getType, Function.identity()));
    }

    public static PaymentStatusEnum of(Integer type) {
        return cache.get(type);
    }

}
